package com.cookie.advice;

import com.cookie.api.exception.JsonResponseException;
import com.cookie.api.model.PO.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author DELL
 */
@ControllerAdvice
public class GlobalExceptionAdvice {

    @ExceptionHandler(JsonResponseException.class)
    @ResponseBody
    public Result<?> responseJsonException(Exception e) {
        return new Result<>("400", e.getMessage(), e.getMessage());
    }
}
